#ifndef MEMOSTORAGE_H
#define MEMOSTORAGE_H

#include <QObject>
#include <QString>
#include <QStringList>
#include <QVariantMap>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QFile>
#include <QStandardPaths>
#include <QDir>
#include <QDebug>

class MemoStorage : public QObject
{
    Q_OBJECT
    
public:
    explicit MemoStorage(QObject *parent = nullptr);
    
    // 加载所有备忘录
    Q_INVOKABLE QVariantList loadMemos();
    
    // 保存备忘录
    Q_INVOKABLE bool saveMemo(int id, const QString &title, const QString &content);
    
    // 删除备忘录
    Q_INVOKABLE bool deleteMemo(int id);
    
    // 获取下一个ID
    Q_INVOKABLE int getNextId();
    
private:
    QString getStoragePath();
    void ensureStorageDir();
    QJsonArray loadJsonArray();
    bool saveJsonArray(const QJsonArray &array);
};

#endif // MEMOSTORAGE_H

